package com.itheima.threaddemo2;

public class Test1 {

    public static void main(String[] args) {

        //多线程的创建方式二：使用Runnable接口的匿名内部类

        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("子线程1输出：" + i);
                }

            }
        };

        Thread t = new Thread(r);

        t.start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("子线程2输出：" + i);
                }

            }
        }).start();

        new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println("子线程3输出：" + i);
            }
        }).start();

        for (int i = 0; i < 5; i++) {
            System.out.println("主线程输出：" + i);
        }
    }
}
